package com.xwdeshj.utils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by BKWJA on 2018/12/19.
 */
public class Base {

    /**身份信息封装到map*/
    public Map<String, String> session2map(HttpServletRequest req){
        Map<String, String> map=new HashMap<String,String>();
        HttpSession session=req.getSession();
        if (helper.ReadCookieMap(req, "uid_encryptid").toString() != null || helper.ReadCookieMap(req, "admin_role").toString() != null || helper.ReadCookieMap(req, "uid").toString() != null) {
            map.put("uid_encryptid", helper.ReadCookieMap(req, "uid_encryptid").toString());
            map.put("admin_role",helper.ReadCookieMap(req, "admin_role").toString());
            map.put("uid",helper.ReadCookieMap(req, "uid").toString());
        }
        return map;
    }

    //判断是否在线
    public boolean session2(HttpServletRequest req){
        HttpSession session=req.getSession();
        if (helper.ReadCookieMap(req, "uid_encryptid").toString() != null || helper.ReadCookieMap(req, "admin_role").toString() != null || helper.ReadCookieMap(req, "uid").toString() != null) {
           return true;
        }
        return false;
    }
}
